/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.alibaba.druid.pool.DruidPooledConnection;
import java.io.InputStream;
import java.util.Properties;

/**
 *
 * @author hsc
 */
public class DruidDataSourceUtil {
    
    public DruidDataSource getDataSource() throws Exception{
            Properties configProperties = new Properties();
            InputStream config_file_input = DruidDataSourceUtil.class.getResourceAsStream("ConfigureProperties.properties");
            configProperties.load(config_file_input);
//            System.out.print(config_file_input);
//                        System.exit(0);
            DruidDataSource data_source = (DruidDataSource) DruidDataSourceFactory.createDataSource(configProperties);
            return data_source;
    }
    
    public DruidPooledConnection getDruidConnection(DruidDataSource druid_source) throws Exception{
    
        DruidPooledConnection conn = druid_source.getConnection();
        return conn;
    }
    
}
